package com.kaibes.module.email.sender;

import java.io.IOException;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.ObjectCodec;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonNode;

public class MailTemplatePostDeserialize extends JsonDeserializer<MailTemplatePost> {

	@Override
	public MailTemplatePost deserialize(JsonParser p, DeserializationContext ctxt)
			throws IOException, JsonProcessingException {
		ObjectCodec oc = p.getCodec();
        JsonNode node = oc.readTree(p);
        MailTemplatePost data = new MailTemplatePost();
        data.setKey(node.get("key").asText());
        data.setTitle(node.get("title").asText());
        data.setEmailContent(node.get("emailContent").asText());
        data.setHtml(node.get("html").asText());
        data.setRemark(node.get("remark").asText());
		return data;
		
	}

}
